<?php require_once('../Connections/CrossFit.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
  $updateSQL = sprintf("UPDATE Login SET Password=SHA1(%s), Active=%s WHERE ID=%s",
                       GetSQLValueString($_POST['Password'], "text"),
                       GetSQLValueString($_POST['Active'], "int"),
                       GetSQLValueString($_POST['ID'], "text"));

  mysql_select_db($database_CrossFit, $CrossFit);
  $Result1 = mysql_query($updateSQL, $CrossFit) or die(mysql_error());

  $insertGoTo = "http://development.crossfit26.com/app?resetmessage='Your password has been reset.'";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header("Location: http://development.crossfit26.com/app?resetmessage=Password Reset");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Reset Password</title>
</head>

<body>
<center><img src="ajax-loader.gif" width="32" height="32" style="margin-top:150px;"><p>Processing...</p>

<p>
 
</p>
</center>



<script type="text/javascript">
<!--
//window.location = "http://development.crossfit26.com/app"
//-->
</script>


</body>
</html>
